package com.lagou.nettyspringboot.controller;

import org.apache.tomcat.util.http.ResponseUtil;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.Optional;

/**
 * @description:
 * @author: yx
 * @date: 2021/12/2 9:32
 */
@RestController
@RequestMapping("/file")
public class FileInfoController {

    @PostMapping("/upload")
    public void upload(@RequestPart MultipartFile file) throws IOException {
        if (!file.isEmpty()) {
            try {
                String filePath = "D:\\Dev\\PolicyData\\Temp.xlsx";

                File dest = new File(filePath);
                file.transferTo(dest);

            }
            catch (Exception ex) {
                ex.printStackTrace();
            }
        }
    }

}
